package guoanmaker.operator.business.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import guoanmaker.operator.business.model.InRoundPhone;
import guoanmaker.operator.business.service.OperatorCompanyServiceNewServiceInterface;
import guoanmaker.operator.helper.common.AjaxJson;
import guoanmaker.operator.helper.common.abstractobj.ApiController;
import io.swagger.annotations.ApiOperation;
/**
 * 
    * @ClassName: OperatorCompanyServiceNewController  
    * @Description: 运营后台企业服务配置  
    * @author lsy  
    * @date 2017年12月16日 下午3:11:15    
    *
 */
@RestController
@RequestMapping(ApiController.OPERATOR_COMPANY_SERVICE_NEW)
public class OperatorCompanyServiceNewController {
	@Autowired
	private OperatorCompanyServiceNewServiceInterface operatorCompanyServiceNewServiceInterface;
	/**
	 * 
	    * @Title: saveOperatorCompanyServiceNew  
	    * @Description: 运营后台保存企业服务  
	    * @param @param inRoundPhone
	    * @param @return      
	    * @return AjaxJson      
	    * @throws
	 */
	
	@ApiOperation(value = "保存企业服务", notes = "保存企业服务")
	@PostMapping("saveOperatorCompanyServiceNew")
	public AjaxJson saveOperatorCompanyServiceNew(@RequestBody InRoundPhone inRoundPhone) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			operatorCompanyServiceNewServiceInterface.deleteOperatorCompanyServiceNewRound(inRoundPhone);
			operatorCompanyServiceNewServiceInterface.saveOperatorCompanyServiceNew(inRoundPhone);
			ajaxJson.setSuccess(true).setStatus(200).setData(null).setMsg("操作成功");
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}
	/**
	 * 
	    * @Title: findCommodityByCommodityCode  
	    * @Description: 输入商品编号查询商品信息  
	    * @param @param commodityCode
	    * @param @return      
	    * @return AjaxJson      
	    * @throws
	 */
/*	@ApiOperation(value = "查询商品编号", notes = "查询商品编号")
	@PostMapping("findCommodityByCommodityCode")
	public AjaxJson findCommodityByCommodityCode(Integer commodityCode) {
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(operatorCompanyServiceNewServiceInterface.findProvideCommodity(commodityCode)).setMsg("操作成功");
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}*/
	/**
	 * 
	    * @Title: findCommodityByServerTypeId  
	    * @Description: 传入商品编号、二级服务 查询商品属于二级服务   
	    * @param @param commodityCode
	    * @param @param serviceTypeId
	    * @return AjaxJson      
	    * @throws
	 */
/*	@ApiOperation(value = "查询商品属于该二级分类", notes = "查询商品属于该二级分类")
	@PostMapping("findCommodityByServerTypeId")
	public AjaxJson findCommodityByServerTypeId(Integer commodityCode, String serviceTypeId) {
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(operatorCompanyServiceNewServiceInterface.findCommodityByServerTypeId(commodityCode, serviceTypeId)).setMsg("操作成功");
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}*/
	/**
	 * 
	    * @Title: findCommodityByServerTypeId  
	    * @Description: 传入商品编号、二级服务 查询商品属于二级服务   
	    * @param @param commodityCode
	    * @param @param serviceTypeId
	    * @return AjaxJson      
	    * @throws
	 */
	@ApiOperation(value = "查询并验证商品", notes = "查询并验证商品")
	@PostMapping("findCommodity")
	public AjaxJson findCommodity(Integer commodityCode, String serviceTypeId, String cityId) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(operatorCompanyServiceNewServiceInterface.findCommodity(commodityCode, serviceTypeId, cityId)).setMsg("操作成功");
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}
	/**
	 * 
	    * @Title: findAllOperatorCompanyServiceNew
	    * @Description: 根据cityId 查询 所有 企业服务
	    * @param @param cityId
	    * @return AjaxJson  
	    * @throws
	 */
	@ApiOperation(value = "根据cityId返回所有企业服务", notes = "根据cityId返回所有企业服务")
	@PostMapping("findAllOperatorCompanyServiceNew")
	public AjaxJson findAllOperatorCompanyServiceNew(String cityId) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(operatorCompanyServiceNewServiceInterface.findAllOperatorCompanyServiceNew(cityId)).setMsg("操作成功");
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}

}
